package com.lnj.messages.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lnj.bean.dto.ProductDTO;
import com.lnj.bean.model.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Set;

/**
 * 商品数据访问接口
 */
@Mapper
public interface ProductMapper extends BaseMapper<Product> {
    @Select("SELECT \n" +
            "    p.productId AS productId,\n" +
            "    p.categoryId AS categoryId,\n" +
            "    p.productName AS productName,\n" +
            "    p.mainImage AS mainImage,\n" +
            "    p.subImages AS subImages,\n" +
            "    p.detail AS detail,\n" +
            "    p.price AS price,\n" +
            "    p.originalPrice AS originalPrice,\n" +
            "    p.productStatus AS productStatus,\n" +
            "    c.categoryName AS categoryName\n" +
            "FROM product p\n" +
            "LEFT JOIN category c ON p.categoryId = c.categoryId\n" +
            "WHERE p.productStatus = 1 AND p.updateTime >= DATE_SUB(NOW(), INTERVAL 1 DAY);")
    List<ProductDTO> findTodayUpdateProduct();

    @Select("select productId from Product where productStatus = 1")
    List<Long> selectAllProductId();
}

